package com.qianfeng.biquge.controller;


import com.qianfeng.biquge.pojo.Users;
import com.qianfeng.biquge.service.IUserService;
import com.qianfeng.biquge.vo.R;
import com.qianfeng.biquge.dto.UserDto;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.text.ParseException;

@RestController
@RequestMapping("/user")
public class UserController {

    @Autowired
    private IUserService userService;

    @PostMapping("/newuser")
    public R addUser(@RequestBody UserDto userDto) {

        userService.addUser(userDto);
        return R.setOk(null);
    }

    @GetMapping("/login")
    public R login(@RequestBody UserDto userDto) throws ParseException {

        Users users = userService.login(userDto);

        return R.setOk(users);

    }




}
